package com.demo01.d01;

import java.util.concurrent.*;

/**
 * @Author: root
 * @Date: 2018/11/15 18:09
 */
public class Main01 {
    public static void main(String[] args) {
        ExecutorService pool = Executors.newFixedThreadPool(1);
        Future<Integer> c1 = pool.submit(new MyCallable());
        try {
            System.out.println(c1.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        pool.shutdown();
    }
}

class MyCallable implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        int sum = 0;
        for (int i = 0; i < 3; i++) {
            sum += i;
        }
        return sum;
    }
}
